<template>
  <Container class="supplersign-edit">
    <!-- 基础设置 -->
    <div class="container-header title title-center" slot="header">
      月度积分返利审核
      <Button
        size="large"
        class="fl btn-back"
        icon="ios-arrow-back"
        @click="jumpPrevPage"
      >返回</Button>
    </div>
    <DefaultEditItem ref="defaultForm" :id="id" :isCheck="isCheck"></DefaultEditItem>
    <div class="container-footer bg-white" slot="footer" v-if="isCheck">
      <Button type="primary" size="large" @click="onSave" :disabled="disabled">审核</Button>
    </div>
  </Container>
</template>
<script>
  import DefaultEditItem from "./edit/DefaultEditItem"
  export default {
    name: "",
    components: {
      DefaultEditItem
    },
    data() {
      return {
        id: this.$route.query.id,
        disabled: false,
        isCheck: this.$route.query.from === 'check' ? true : false
      }
    },
    methods: {
      jumpPrevPage() {
        this.$router.back()
      },
      onSave() {
        this.$refs["defaultForm"].$refs["form"].validate(valid => {
          if (valid) {
            this.disabled = true
            let formData = this.$refs["defaultForm"].form
            let param = {
              id: this.id,
              auditIntegral: formData.auditIntegral,
              auditRebate: formData.auditRebate,
              auditIntegralRemark: formData.auditIntegralRemark,
              auditRebateRemark: formData.auditRebateRemark
            }
            this.$jsonPost(`/assets/store_int_month/audit`, param).then(() => {
              this.$Notice.success({
                title: `审核成功`
              })
              setTimeout(() => {
                this.$router.replace('/welfare/integralMonth/list')
              }, 200)
            }).catch(() => {
              this.$Notice.success({
                title: `审核失败`
              })
              this.disabled = false
            })
          }
        })
      }
    }
  };
</script>

